﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Clients_Control_down : System.Web.UI.UserControl
{
    private String strLiDiv = "<li> <a href='" + Constant.ROOT_PATH + "$link'>$text</a></li>";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            LoadAbout();
            String strPage = "";
            try
            {
                strPage = Request.Params["Pro"].ToString().Trim();
            }
            catch
            {

            }
            lblContentTitle.Text = Constant.ContentTitle(strPage);
        }
    }
    private void LoadAbout()
    {
        int id = 1;
        try
        {
            id = int.Parse(Request.Params["id"].ToString());
        }
        catch
        {
        }

            WebData data = new WebData();
            List<DataLibrary.tbl_Download> arr=data.tbl_Downloads.GetListCache("download", Constant.time);
            this.grdAbout.DataSource = arr.FindAll(p => p.Id==id);
            this.grdAbout.DataBind();
            String url = "";
            List<DataLibrary.tbl_Download> list =arr.FindAll(p=>p.Id < id);
            int l = list.Count;
            for (int i = 0; i < l; i++)
            {
                try
                {
                    if (!string.IsNullOrEmpty(list[i].Title.ToString()))
                    {
                        String str = String.Format("down/{0}/{1}", list[i].Id.ToString(),
                            list[i].Title.ToString().Replace(" ", "-").Replace(".", "").Replace("/", "_").Replace(":",""));
                        url = url + strLiDiv.Replace("$text", list[i].Title.ToString()).Replace("$link", str);
                    }
                }
                catch { }
            }
            ltlDownLoad.Text = url;
            if (string.IsNullOrEmpty(url))
            {
                lbl.Visible = false;
            }
            else {
                lbl.Visible = true;
            }
        


    }
}